//
//  LeaderboardService.m
//  playlive_sdk
//
//  Created by psvn047 on 5/16/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "LeaderboardService.h"

@implementation LeaderboardService

-(void) create: (NSString*) serviceId appId: (NSString*) appId names:(NSMutableArray*) names sortOrder:(NSString*) sortOrder worseScoresAllowed:(BOOL) worseScoresAllowed isVisible:(BOOL) isVisible
{
    NSMutableDictionary * query = [NSMutableDictionary dictionary];
    [query setObject:appId forKey:@"app_id"];
    [query setObject:sortOrder forKey:@"sort_order"];
    [query setObject:[NSString stringWithFormat:@"%i", worseScoresAllowed] forKey:@"worse_scores_allowed"];
    [query setObject:[NSString stringWithFormat:@"%i", isVisible] forKey:@"is_visible"];
    [query setObject:names forKey:@"names"];
    [self callService:serviceId httpMethod:@"POST" httpHost:[self getHTTPHost] path:@"leaderboard" queryParameters:query messageBody:NULL application:[self getApplication] session:[BasicHttpService getSession]];
}
-(void) postScore:(NSString*) serviceId leaderboardId:(NSString*) leaderboardId value:(int) value
{
    NSMutableDictionary * query = [NSMutableDictionary dictionary];
    [query setObject:leaderboardId forKey:@"leaderboard_id"];
    [query setObject:[NSString stringWithFormat:@"%i", value] forKey:@"value"];
    [self callService:serviceId httpMethod:@"POST" httpHost:[self getHTTPHost] path:@"leaderboard/score" queryParameters:query messageBody:NULL application:[self getApplication] session:[BasicHttpService getSession]];
}
-(void) getLeaderboards:(NSString*) serviceId ids:(NSString*) ids
{
     NSString* path = [NSString stringWithFormat:@"leaderboard?ids=%@", ids];
       
    [self callService:serviceId httpMethod:@"GET" httpHost:[self getHTTPHost] path:path queryParameters:NULL messageBody:NULL application:[self getApplication] session:[BasicHttpService getSession]];
}
-(void) getLeaderboard_Score:(NSString*) serviceId leaderboardId:(NSString*) leaderboardId filter:(NSString*) filter limit:(int) limit offset:(int) offset
{

    NSString* path = [NSString stringWithFormat:@"leaderboard/score?leaderboard_id=%@&filter=%@&limit=%i&offset=%i", leaderboardId, filter, limit, offset];

    [self callService:serviceId httpMethod:@"GET" httpHost:[self getHTTPHost] path:path queryParameters:NULL messageBody:NULL application:[self getApplication] session:[BasicHttpService getSession]];
}
@end
